:: [Int] -> Int -package:faktory -package:ghc
Calculate the multiplicity of a multiplet
length returns the length of a finite list as an
Int. It is an instance of the more general
genericLength, the result type of which may be any kind of
number.
>>> length []
0
>>> length ['a', 'b', 'c']
3
>>> length [1..]
* Hangs forever *
A version specialized to lists to avoid errors such as taking length
of Maybe [a] instead of [a]. Such errors are hard to
detect, because the type of elements of the list is not constrained.
Extract the first element of a list, which must be
non-empty.
>>> head [1, 2, 3]
1
>>> head [1..]
1
>>> head []
*** Exception: Prelude.head: empty list
WARNING: This function is partial. You can use case-matching,
uncons or
listToMaybe instead.
Extract the last element of a list, which must be finite
and non-empty.
>>> last [1, 2, 3]
3
>>> last [1..]
* Hangs forever *
>>> last []
*** Exception: Prelude.last: empty list
WARNING: This function is partial. You can use
reverse with
case-matching,
uncons or
listToMaybe instead.
hedgehog Hedgehog.Internal.Prelude,
base-compat Prelude.Compat,
protolude Protolude.Partial,
relude Relude.Unsafe,
universum Universum.Unsafe,
github GitHub.Internal.Prelude,
numhask NumHask.Prelude,
ghc-lib-parser GHC.Prelude.Basic,
rebase Rebase.Prelude,
hledger Hledger.Cli.Script,
linear-base Data.List.Linear,
calligraphy Calligraphy.Prelude,
distribution-opensuse OpenSuse.Prelude Extract the last element of a list, which must be finite
and non-empty.
>>> last [1, 2, 3]
3
>>> last [1..]
* Hangs forever *
>>> last []
*** Exception: Prelude.last: empty list
hedgehog Hedgehog.Internal.Prelude,
base-compat Prelude.Compat,
protolude Protolude.Partial,
snap-core Snap.Test,
relude Relude.Unsafe,
universum Universum.Unsafe,
github GitHub.Internal.Prelude,
numhask NumHask.Prelude,
ghc-lib-parser GHC.Prelude.Basic,
rebase Rebase.Prelude,
hledger Hledger.Cli.Script,
linear-base Data.List.Linear,
distribution-opensuse OpenSuse.Prelude Extract the first element of a list, which must be
non-empty.
>>> head [1, 2, 3]
1
>>> head [1..]
1
>>> head []
*** Exception: Prelude.head: empty list
Extract the first element of a list, which must be
non-empty.
Extract the last element of a list, which must be finite
and non-empty.
Utility function to go from a singleton list to it's element.
Wether or not the argument is a singleton list is only checked in
debug builds.
Extract the last element of a list, which must be finite
and non-empty.
>>> last [1, 2, 3]
3
>>> last [1..]
* Hangs forever *
>>> last []
Exception: Prelude.last: empty list
Extract the first element of a list, which must be
non-empty.
>>> head [1, 2, 3]
1
>>> head [1..]
1
>>> head []
Exception: Prelude.head: empty list
Fold a list using the monoid.
For most types, the default definition for
mconcat will be
used, but the function is included in the class definition so that an
optimized version can be provided for specific types.
>>> mconcat ["Hello", " ", "Haskell", "!"]
"Hello Haskell!"
Fold a list using the monoid. For most types, the default definition
for
mconcat will be used, but the function is included in the
class definition so that an optimized version can be provided for
specific types.